import { ChunkEntityType, ChunkEntityUpdateType } from "../../GameDef";
import { ECSCmp } from "../../lib/kgame/ecs/ECSCmp";
import { IRect } from "../../lib/kgame/util/Defined";

/**
 * 区块实体组件
 */
export class CmpChunkEntity extends ECSCmp {

    type: ChunkEntityType
    /** 区块实体更新类型 */
    updateType: ChunkEntityUpdateType;
    private _aabb: IRect | (() => IRect);

    /**
     * 初始化区块实体组件
     * @param type 区块实体类型
     * @param updateType 区块实体更新类型
     * @param aabb 实体包围盒
     */
    onCreate(type: ChunkEntityType, updateType: ChunkEntityUpdateType, aabb: IRect | (() => IRect)) {
        this.type = type;
        this.updateType = updateType;
        this._aabb = aabb;
        return this;
    }

    /** 实体包围盒 */
    get aabb() {
        return this._aabb instanceof Function ? this._aabb() : this._aabb;
    }

}